home *** CD-ROM | disk | FTP | other *** search
- Path: ntc.nokia.com!usenet
- From: Risto Lankinen <risto.lankinen@ntc.nokia.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Q:order of evaluation
- Date: 29 Jan 1996 09:31:43 GMT
- Organization: Nokia Telecommunications
- Message-ID: <4ei45v$mci@axl02it.ntc.nokia.com>
- References: <4dfhlu$a33$1@mhafn.production.compuserve.com> <hamilton-1801962045570001@dialup-147.austin.io.com> <4dpcfo$293@clarknet.clark.net> <hamilton-2401960104020001@dialup-86.austin.io.com> <3108c867.40236096@nntp.ix.netcom.com> <4eb6kq$ksf@gazette.tandem.com> <31098f8f.11689344@nntp.ix.netcom.com>
- NNTP-Posting-Host: pc-rlankinen.ntc.nokia.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
- Hi!
-
- miker3@ix.netcom.com (Mike Rubenstein) wrote:
- >yun_yeogirl <yyg> wrote:
- >
- >> Michael M Rubenstein wrote :
- >>
- >> [Example:
- >> i = v[i++]; // the behavior is undefined
- >>
- >> i = ++i + 1; // the behavior is undefined
- >>
- [etc...]
-
- Isn't the mere existence of this discussion an adequate reason for
- reconsidering the standard when it comes to the evaluation order of
- such expressions? What I mean is, why does the standard *need* to
- specify that something is 'undefined' when they could be 'defined'
- anyway. This would have the added bonus that no existing programs
- conforming to the standard won't break simply because they were not
- allowed to make assumptions about undefined behaviour, whereas the
- new programs would have the added power of expression without fear
- of the compilers misinterpreting the intent.
-
- For example, instead of...
-
- >> i = ++i + 1; // the behavior is undefined
-
- .. one could define in the standard...
-
- >> i = ++i + 1; // operator+() evaluates and executes
- >> // its arguments in the order of their
- >> // associativity, ie. '++i' first, the
- >> // constant expression '1' next, and
- >> // the operator+() last. Finally, the
- >> // result is assigned to 'i'. Thus the
- >> // example equals to 'i = i + 2'.
-
- .. and within one version cycle all compilers will behave same.
-
- Or, for curiosity's sake, why not?
-
- terv: Risto L.
-
- --
- Risto Lankinen / System Engineer ***************************************
- Nokia Telecommunications, * 2 2 *
- Cellular Data; Helsinki, Finland. * 2 -1 is PRIME! Now working on 2 +1 *
- risto.lankinen@ntc.nokia.com ***************************************
-
-
-